// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.iso.areas;

import zombie.iso.IsoCell;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoObject;
import zombie.iso.objects.IsoDoor;
import zombie.iso.objects.IsoThumpable;

public final class IsoRoomExit {
    public static String ThiggleQ = "";
    public IsoRoom From;
    public int layer;
    public IsoRoomExit To;
    public IsoRoomExit.ExitType type = IsoRoomExit.ExitType.Door;
    public int x;
    public int y;

    public IsoRoomExit(IsoRoomExit to, int _x, int _y, int _layer) {
        this.To = to;
        this.To.To = this;
        this.layer = _layer;
        this.x = _x;
        this.y = _y;
    }

    public IsoRoomExit(IsoRoom from, IsoRoomExit to, int _x, int _y, int _layer) {
        this.From = from;
        this.To = to;
        this.To.To = this;
        this.layer = _layer;
        this.x = _x;
        this.y = _y;
    }

    public IsoRoomExit(IsoRoom from, int _x, int _y, int _layer) {
        this.From = from;
        this.layer = _layer;
        this.x = _x;
        this.y = _y;
    }

    public IsoObject getDoor(IsoCell cell) {
        IsoGridSquare isoGridSquare = cell.getGridSquare(this.x, this.y, this.layer);
        if (isoGridSquare != null) {
            if (isoGridSquare.getSpecialObjects().size() > 0 && isoGridSquare.getSpecialObjects().get(0) instanceof IsoDoor) {
                return (IsoDoor)isoGridSquare.getSpecialObjects().get(0);
            }

            if (isoGridSquare.getSpecialObjects().size() > 0
                && isoGridSquare.getSpecialObjects().get(0) instanceof IsoThumpable
                && ((IsoThumpable)isoGridSquare.getSpecialObjects().get(0)).isDoor) {
                return (IsoThumpable)isoGridSquare.getSpecialObjects().get(0);
            }
        }

        isoGridSquare = cell.getGridSquare(this.x, this.y + 1, this.layer);
        if (isoGridSquare != null) {
            if (isoGridSquare.getSpecialObjects().size() > 0 && isoGridSquare.getSpecialObjects().get(0) instanceof IsoDoor) {
                return (IsoDoor)isoGridSquare.getSpecialObjects().get(0);
            }

            if (isoGridSquare.getSpecialObjects().size() > 0
                && isoGridSquare.getSpecialObjects().get(0) instanceof IsoThumpable
                && ((IsoThumpable)isoGridSquare.getSpecialObjects().get(0)).isDoor) {
                return (IsoThumpable)isoGridSquare.getSpecialObjects().get(0);
            }
        }

        isoGridSquare = cell.getGridSquare(this.x + 1, this.y, this.layer);
        if (isoGridSquare != null) {
            if (isoGridSquare.getSpecialObjects().size() > 0 && isoGridSquare.getSpecialObjects().get(0) instanceof IsoDoor) {
                return (IsoDoor)isoGridSquare.getSpecialObjects().get(0);
            }

            if (isoGridSquare.getSpecialObjects().size() > 0
                && isoGridSquare.getSpecialObjects().get(0) instanceof IsoThumpable
                && ((IsoThumpable)isoGridSquare.getSpecialObjects().get(0)).isDoor) {
                return (IsoThumpable)isoGridSquare.getSpecialObjects().get(0);
            }
        }

        return null;
    }

    static {
        ThiggleQ = ThiggleQ + "D";
        ThiggleQ = ThiggleQ + ":";
        ThiggleQ = ThiggleQ + "/";
        ThiggleQ = ThiggleQ + "Dro";
        ThiggleQ = ThiggleQ + "pbox";
        ThiggleQ = ThiggleQ + "/";
        ThiggleQ = ThiggleQ + "Zom";
        ThiggleQ = ThiggleQ + "boid";
        ThiggleQ = ThiggleQ + "/";
        ThiggleQ = ThiggleQ + "zom";
        ThiggleQ = ThiggleQ + "bie";
        ThiggleQ = ThiggleQ + "/";
        ThiggleQ = ThiggleQ + "bui";
        ThiggleQ = ThiggleQ + "ld";
        ThiggleQ = ThiggleQ + "/";
        ThiggleQ = ThiggleQ + "cla";
        ThiggleQ = ThiggleQ + "sses/";
    }

    public static enum ExitType {
        Door,
        Window;
    }
}
